﻿using System;
using System.Web.UI.WebControls;
using Altairis.Sewen;

namespace Altairis.FluffyCloud.WebCore.Pages.Sewen {

    public partial class PageNew : System.Web.UI.Page {

        protected void Page_Load(object sender, EventArgs e) {
        }

        protected void PageFormView_ItemCommand(object sender, FormViewCommandEventArgs e) {
            Response.RedirectToRoute("HomePage");
        }

        protected void PageFormView_ItemInserted(object sender, FormViewInsertedEventArgs e) {
            // Get title of newly inserted page
            var newPageSlug = SewenPage.GetSlug(e.Values["Title"] as string);

            // Redirect to the new page
            Response.RedirectToRoute("WikiPage", new { slug = newPageSlug });
        }
    }
}